import DBConnection from "../../service/unit/mysql";

/*
* 将article表中值为特定anthology的行中的is_active置为0
* 同时也将anthology表中特定的行置为0
* */
export async function deleteAnthology(conn:DBConnection, TABLE_NAME:string, CONDITION) {
    const {storeId} = CONDITION;
    const TABLE_NAME_ARTICLE = 'article';
    const RESULT = await conn.Query.queryWhereNoneConditionEncode(TABLE_NAME,{id:storeId});
    const ANTHOLOGY = RESULT[0].anthology;

    await conn.Update.updateNoneEncodeDATA(TABLE_NAME,{is_active:0},{KEY:'anthology',SIGN:'=',VALUE:ANTHOLOGY});

    await conn.Update.updateNoneEncodeDATA(TABLE_NAME_ARTICLE,
        {is_active:0},
        {KEY:'anthology',SIGN:'=',VALUE:ANTHOLOGY});

    return 'ok'
}
